/* @Author karl
** @Date 2025/11/1 10:59:00
** @Desc
 */
package g_phoenixLimiter

import "time"

// PhoenixLimiterConfig 限流器的配置
type PhoenixLimiterConfig struct {
	Enable            bool
	PermitsPerSecond  int
	BlackListCount    int8
	keyExtractor      func(args ...interface{}) string
	BlacklistDuration time.Duration
	RecordDuration    time.Duration
	FallbackFunc      func(key string, reason string) (interface{}, error)
}

type LimiterResult struct {
	Allowed bool
	Reason  string
	Message string
}

type BlacklistEntity struct {
	Key        string
	Counts     int8
	AddTime    time.Time
	ExpireTime time.Time
}

// RateLimiterStats 限流统计信息
type RateLimiterStats struct {
	TotalRequests    int64
	RejectedRequests int64
	RejectionRate    float64
	BlacklistedCount int32
	UpdateTime       time.Time
}
